package login;

import java.util.ArrayList;

public class User {
	private String email;
	private String password;
	private ArrayList<Roletype> belongsTo;
	
	public User(String email, String pass, ArrayList<Roletype> belongsTo) {
		this.email = email;
		this.setPassword(pass);
		this.belongsTo = belongsTo;
	}
	
	public String getEmail() {
		return this.email;
	}
	
	/**
	 * Fetch the lists of roles assigned to the user
	 * 
	 * @return Roles assigned to the user
	 */
	public ArrayList<Roletype> getBelongsTo() {
		return this.belongsTo;
	}
	
	/**
	 * Adds a right
	 * 
	 * @param urt
	 *            right to be added
	 * @return true
	 */
	public boolean addRight(Roletype urt) {
		boolean result = true;
		if (!this.belongsTo.contains(urt)) {
			result = this.belongsTo.add(urt);
		}
		return result;
	}
	
	/**
	 * Removes a right
	 * 
	 * @param urt
	 *            right to be removed
	 * @return true if the right was in the list
	 */
	public boolean removeRight(Roletype urt) {
		boolean result = true;
	
		result = this.belongsTo.remove(urt);
		
		return result;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

}


